package com.anyisn.anyflickr.shell.view
{
	import org.puremvc.as3.multicore.interfaces.INotification;
	import org.puremvc.as3.multicore.patterns.mediator.Mediator;
	
	import com.anyisn.anyflickr.shell.ShellFacade;
	import com.anyisn.anyflickr.modules.PhotosSlide.PhotosSlideModule;
	import com.anyisn.anyflickr.modules.PhotosSlide.view.component.PhotosSlideWindow;
	
	public class PhotosSlideModuleMediator extends Mediator
	{
		public function PhotosSlideModuleMediator(viewComponent:PhotosSlideModule)
		{
			super(viewComponent.getID(), viewComponent);
		}
		
		override public function onRegister():void
		{
			psModule.exportPhotosSlideWindow();
		}
		
		override public function listNotificationInterests():Array
		{
			return [ ShellFacade.CLOSE_PHOTOS_SLIDE_WINDOW
				   ];	
		}
		
		override public function handleNotification( note:INotification ):void
		{
			switch( note.getName() )
			{
				case  ShellFacade.CLOSE_PHOTOS_SLIDE_WINDOW:
					var win:PhotosSlideWindow = note.getBody() as PhotosSlideWindow;
					if(win.moduleID == psModule.getID()) {
						viewComponent = null;
						facade.removeMediator(this.getMediatorName());
					}
					break;
			}
		}
		
		private function get psModule():PhotosSlideModule
		{
			return viewComponent as PhotosSlideModule;
		}
	}
}